/*
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-09-04 15:40:59
 * @LastEditTime: 2019-09-06 13:53:18
 * @LastEditors: Please set LastEditors
 */
import React,{Component} from "react"
import PropTypes from "prop-types"
// context 是全局的  组件里申明  搜友子元素都可以直接获取
class Page extends Component{
    static childContextTypes ={
        user:PropTypes.string
    }
    constructor(props){
        super(props);
        this.state = {user:"蜗牛"}
    }
    getChildContext(){
        return this.state
    }
    render(){
        return (
            <div>
                <SideNav></SideNav>
            </div>
        )
    }
}

class SideNav extends Component{
    render(){
        return (
            <div>
                <h1>侧边导航</h1>
                <NavBar></NavBar>
            </div>
        )
    }
}

class NavBar extends Component{
    static contextTypes ={
        user:PropTypes.string
    }
    constructor(props,context){
        super(props,context);
    }
    render(){
        console.log(this)
        return (
            <div>
                <h2>{this.context.user}导航栏</h2>
            </div>
        );
    }
}

// function Test(props,context){
//     console.log(context)
//     return (
//         <div>
//             {context.user}
//         </div>
//     )
// }

export default Page;